<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // navigator   => 设备相关的信息  => window.navigator

    // 属性:
    // userAgent  用户代理信息


    // PC: Windows  Mac
    // 移动端: iPhone  Android   iPad  


    // console.log(navigator);
    // console.log(navigator.userAgent);


    // 判断设备类型 (PC / 移动)

    var userAgent = navigator.userAgent;
    var appList = ["iPhone", "Android", "iPad"];

    var flag = false; //假设是PC
    for (var i = 0; i < appList.length; i++) {
        var app = appList[i];
        if (userAgent.includes(app)) {
            flag = true;
            break;
        }
    }

    if (flag) {
        console.log("移动:", app);
    } else {
        console.log("PC");
    }






</script>

</html>